import cv2 as cv
import matplotlib.pyplot as plt

img = cv.imread('lena.jpg')

# 将图片转换为灰度图片
gray_img = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
L = 255

plt.subplot(1,2,1)
plt.title("Original Image")
plt.imshow(gray_img, cmap='gray')
plt.subplot(1,2,2)
plt.title("Negative Image")
plt.imshow(L - gray_img, cmap='gray')
plt.show()